﻿ 
using SHKF.B2C.Model.Entity.WorkingCenter;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;

namespace SHKF.B2C.BLL.WorkingCenter
{
    /// <summary>
    /// 虚拟产品总库存
    /// </summary>
    public class WareHouseDataAllBLL : WorkingCenterBLL
    {
        public WareHouseDataAllBLL(SqlSugarClient db) : base(db)
        {
            
        }

        public int Save(WareHouseDataAllEntity info)
        {
            int result = 0;
            WareHouseDataAllEntity oldInfo = this.db.Queryable<WareHouseDataAllEntity>()
                .Where(ww => ww.ShopVSN == info.ShopVSN
                       && ww.ProductVSN == info.ProductVSN)
                .First();

            if (oldInfo != null)
            {
                oldInfo.Qty = info.Qty;
                result = this.db.Updateable<WareHouseDataAllEntity>(oldInfo)
                    .ExecuteCommand();
            }
            else
            {
                result = this.db.Insertable<WareHouseDataAllEntity>(info)
                    .ExecuteCommand();
            }
            return result;
        }
    }
}
